//
//  MainViewController.m
//  UI08_2_页面间传值(属性_协议代理)
//
//  Created by Scott on 15/4/28.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "MainViewController.h"
#import "SecondViewController.h"

@interface MainViewController ()
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UILabel *label;

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, self.view.frame.size.width - 40, 40)];
    _textField.borderStyle = 3;
    _textField.placeholder = @"请输入用户名";
    [self.view addSubview:_textField];
    [_textField release];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(20, 150, 100, 40);
    [button setTitle:@"确定" forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}

- (void)buttonClicked:(UIButton *)button
{
#pragma mark - 知识点1 属性传值(从前向后传值)
    SecondViewController *second = [[SecondViewController alloc] init];
    
    /* 第二界面的属性赋值 */
    second.recervieString = self.textField.text;
    
    /* 第二页面的背景颜色属性 */
    second.view.backgroundColor = [UIColor orangeColor];
    
    /* push 第二页面 */
    [self.navigationController pushViewController:second animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc
{
    [_label release];
    [_textField release];
    [super dealloc];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
